<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org"
      lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Template • TodoMVC</title>
    <link rel="stylesheet" th:href="@{/webjars/todomvc-common/base.css}">
    <link rel="stylesheet" th:href="@{/webjars/todomvc-app-css/index.css}">
</head>
<body>
<section class="todoapp">
    <header class="header">
        <h1>todos</h1>
        <form th:action="@{/}" method="post" th:object="${item}">
            <input class="new-todo" placeholder="What needs to be done?" autofocus
                   th:field="*{title}">
        </form>
    </header>
    <!-- This section should be hidden by default and shown when there are todos -->
    <section class="main" th:if="${totalItemCount > 0}">
        <form th:action="@{/toggle-all}" th:method="put">
            <input id="toggle-all" class="toggle-all" type="checkbox"
                   onclick="this.form.submit()">
            <label for="toggle-all">Mark all as complete</label>
        </form>
        <ul class="todo-list" th:remove="all-but-first">
            <li th:insert="fragments :: todoItem(${item})" th:each="item : ${todoItems}" th:remove="tag">
            </li>
            <!-- These are here just to show the structure of the list items -->
            <!-- List items should get the class `editing` when editing and `completed` when marked as completed -->
            <li class="completed">
                <div class="view">
                    <input class="toggle" type="checkbox" checked>
                    <label>Taste JavaScript</label>
                    <button class="destroy"></button>
                </div>
                <input class="edit" value="Create a TodoMVC template">
            </li>
            <li>
                <div class="view">
                    <input class="toggle" type="checkbox">
                    <label>Buy a unicorn</label>
                    <button class="destroy"></button>
                </div>
                <input class="edit" value="Rule the web">
            </li>
        </ul>
    </section>
    <!-- This footer should be hidden by default and shown when there are todos -->
    <footer class="footer" th:if="${totalItemCount > 0}">
        <th:block th:unless="${activeItemCount == 1}">
            <span class="todo-count"><strong th:text="${activeItemCount}">0</strong> items left</span>
        </th:block>
        <th:block th:if="${activeItemCount == 1}">
            <span class="todo-count"><strong>1</strong> item left</span>
        </th:block>
        <ul class="filters">
            <li>
                <a th:href="@{/}"
                   th:classappend="${todoFilter.name() == 'ALL'?'selected':''}">All</a>
            </li>
            <li>
                <a th:href="@{/active}"
                   th:classappend="${todoFilter.name() == 'ACTIVE'?'selected':''}">Active</a>
            </li>
            <li>
                <a th:href="@{/completed}"
                   th:classappend="${todoFilter.name() == 'COMPLETED'?'selected':''}">Completed</a>
            </li>
        </ul>
        <form th:action="@{/completed}" th:method="delete"
              th:if="${completedItemCount > 0}">
            <button class="clear-completed">Clear completed</button>
        </form>
    </footer>
</section>
<footer class="info">
    <p>Double-click to edit a todo</p>
</footer>
<script th:src="@{/webjars/todomvc-common/base.js}"></script>
</body>
</html>
